package com.liip.platform.common;

import lombok.Data;

import java.io.Serializable;

import io.swagger.annotations.ApiModelProperty;

/**
 * 返回结果类
 *
 * @param <T> 类型
 * @author 罗林
 * @date 2020/03/26
 */
@Data
public class ReturnT<T> implements Serializable {
	public static final long serialVersionUID = 42L;

	public static final int SUCCESS_CODE = 200;
	public static final int FAIL_CODE = 500;
	public static final ReturnT<String> SUCCESS = new ReturnT<>(null);
	public static final ReturnT<String> FAIL = new ReturnT<>(FAIL_CODE, null);
	
	@ApiModelProperty("状态码 0失败 1成功 ")
	private int code;
	@ApiModelProperty("返回信息")
	private String msg;
	 @ApiModelProperty("返回数据")
	private T data;
	
	public ReturnT(Integer code, String msg) {
		this.code = code;
		this.msg = msg;
	}
	public ReturnT(T data) {
		this.code = SUCCESS_CODE;
		this.data = data;
	}
	
	public ReturnT(Integer code, String msg, T data) {
        this.code = code;
        this.msg = msg;
        this.data = data;
    }
	public int getCode() {
		return code;
	}
	public void setCode(int code) {
		this.code = code;
	}
	public String getMsg() {
		return msg;
	}
	public void setMsg(String msg) {
		this.msg = msg;
	}
	public T getData() {
		return data;
	}
	public void setData(T data) {
		this.data = data;
	}

}
